package com.eol.common.pay;

import com.ijpay.alipay.AliPayApiConfig;
import com.ijpay.wxpay.WxPayApiConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * Created with IntelliJ IDEA.
 * User: liulinhui
 * Date: 2020/5/25
 * Time: 3:08 PM
 * Description: PayConfig
 */
@Configuration
public class PayConfig {


    /**
     * 构造config
     *
     * @return WxPayApiConfig
     */
    @Bean
    public WxPayApiConfig calWxConfig(WxPayBean wxPayBean) {
        return WxPayApiConfig.builder()
                .appId(wxPayBean.getAppId())
                .mchId(wxPayBean.getMchId())
                .partnerKey(wxPayBean.getPartnerKey())
                .certPath(wxPayBean.getCertPath())
                .build();
    }

    @Bean
    public AliPayApiConfig aliPayApiConfig(AliPayBean aliPayBean){
        return AliPayApiConfig.builder()
                .setAppId(aliPayBean.getAppId())
                .setAliPayPublicKey(aliPayBean.getPublicKey())
                .setCharset("UTF-8")
                .setPrivateKey(aliPayBean.getPrivateKey())
                .setSignType("RSA2")
                .setServiceUrl(aliPayBean.getServiceUrl())
                // 普通公钥方式
                .build();
    }
}
